<template>
  <el-container class="home-container">
    <el-header>
      <div>
        <img src="../assets/logo.jpg" alt />
        <span>电商后台管理系统</span>
      </div>
      <el-dropdown>
        <img
          src="../assets/f_head.jpg"
          alt
          class="el-icon-arrow-down el-icon--right el-dropdown-link el-icon-arrow-down el-icon--right"
        />
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>用户信息</el-dropdown-item>
          <el-dropdown-item>用户设置</el-dropdown-item>
          <el-dropdown-item divided>退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </el-header>
    <el-container>
      <!-- 左菜单 -->
      <el-aside :width="isCollapse?'64px':'200px'">
        <div class="toggle-button" @click="toggleCollapse">||||</div>
        <el-menu
          background-color="#333744"
          text-color="#fff"
          active-text-color="#ffd04b"
          unique-opened
          :collapse="isCollapse"
          :collapse-transition="false"
          router
        >
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>用户管理</span>
            </template>
            <el-menu-item index="/user/users">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>用户列表</span>
              </template>
            </el-menu-item>
          </el-submenu>

          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>角色管理</span>
            </template>
            <el-menu-item index="/role/roles">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>角色列表</span>
              </template>
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <!-- 右侧内容 -->
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  name: 'home',
  data() {
    return {
      isCollapse: false
    }
  },
  methods: {
    // 菜单折叠和张开
    toggleCollapse() {
      this.isCollapse = !this.isCollapse
    }
  }
}
</script>

<style lang="less" scoped>
.home-container {
  height: 100%;
}
.el-header {
  background-color: #373d41;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  font-size: 20px;
  > div {
    display: flex;
    align-items: center;
    img {
      height: 50px;
      width: 120px;
      // border-radius: 50%;
      // background-color: #eee;
    }
    span {
      display: flex;
      align-items: center;
      font-size: 22px;
      padding-left: 10px;
    }
  }
  .el-dropdown {
    img {
      height: 40px;
      width: 40px;
      border-radius: 50%;
      background-color: #eee;
      display: flex;
      align-items: center;
    }
  }
}
.el-aside {
  background-color: #333744;
  .el-menu {
    border-right: none;
  }
}
.el-main {
  background-color: #eaedfe;
}
.toggle-button {
  background-color: #4a5064;
  font-size: 15px;
  line-height: 24px;
  color: white;
  text-align: center;
  // letter-spacing: 1em;
  cursor: pointer;
}
</style>
